package edu.hawaii.halealohacli;

import java.io.ByteArrayInputStream;
import org.junit.Test;
import edu.hawaii.HaleAlohaCli;

/**
 * tests the validation of arguments passed through command line based on the command and number of
 * arguments.
 * 
 * @author John MacMillan
 * @author Mitchell Kupfer
 * @author Bryson Hori
 */
public class TestValidation {

  private String command1;
  private String command2;
  private String command3;
  private String command4;
  private String command5;
  private String command6;

  /**
   * Initializes test inputs for the validation tests.
   */
  public TestValidation() {

    command1 = "rank-towers 2011-11-23 2011-11-23 ";
    command2 = "daily-energy Mokihana 2011-11-23";
    command3 = "energy-since Lehua-E 2011-11-23";
    command4 = "current-power Ilima-A";
    command5 = "help";
    command6 = "quit";
  }

  /**
   * Sends main some arguments.
   * 
   * @throws Exception if fails.
   */
  @Test
  public void testInputs() throws Exception {
    // HaleAlohaCli aloha = new HaleAlohaCli();
    ByteArrayInputStream in = new ByteArrayInputStream(command1.getBytes());
    System.setIn(in);

    String[] strings = new String[3];
    strings[0] = "empty";

    HaleAlohaCli.main(strings);

    ByteArrayInputStream in2 = new ByteArrayInputStream(command2.getBytes());
    System.setIn(in2);

    HaleAlohaCli.main(strings);

    ByteArrayInputStream in3 = new ByteArrayInputStream(command3.getBytes());
    System.setIn(in3);

    HaleAlohaCli.main(strings);

    ByteArrayInputStream in4 = new ByteArrayInputStream(command4.getBytes());
    System.setIn(in4);

    HaleAlohaCli.main(strings);

    ByteArrayInputStream in5 = new ByteArrayInputStream(command5.getBytes());
    System.setIn(in5);

    HaleAlohaCli.main(strings);

    ByteArrayInputStream in6 = new ByteArrayInputStream(command6.getBytes());
    System.setIn(in6);

    HaleAlohaCli.main(strings);

  }
}
